package ans.p27;

/**
 * #      27
 * 名称   移除元素
 * 链接   https://leetcode-cn.com/problems/remove-element
 * 题解   [2745](https://leetcode-cn.com/problems/remove-element/solution)
 * 通过率 59.1%
 * 难道   简单
 */

class Solution {
    public int removeElement(int[] nums, int val) {
        int len = nums.length;
        for (int i = 0; i < len; i++) {
            if (nums[i] == val) {
                nums[i] = nums[len - 1];
                len--;
                i--;
            }
        }
        return len;
    }

}